home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample PMSAM / PMSAM Framework / RoboSamSlot / EnclosFile.cp < prev    next >
Encoding:
Text File  |  1995-07-28  |  3.5 KB  |  161 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        EnclosFile.cp
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    David AKhond
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <2>     2/27/95    TMH        adapt to use ETO16 universal headers
  13.  
  14.     To Do:
  15. */
  16.  
  17.  
  18.  
  19. #include "EnclosFile.h"
  20.  
  21. #include    <Memory.h>
  22.  
  23. #ifndef __Debug__
  24. #include "Debug.h"
  25. #endif
  26.  
  27. #ifndef __UFAILURE__
  28. #include "UFailure.h"
  29. #endif
  30.  
  31. #ifndef __LogErrors__
  32. #include "LogErrors.h"
  33. #endif
  34.  
  35. #pragma segment AOCEEnclosure
  36.  
  37.  
  38. //-------------------------------------------------
  39.  
  40. CEnclosFileSummary::CEnclosFileSummary(unsigned long  fileIndex, unsigned long /*fileSize*/, OSType fileType, OSType    fileCreator, StringPtr    fileName,
  41.                             unsigned long  resourceForkOffset, unsigned long  resourceForkLength, unsigned long  dataForkOffset,
  42.                             unsigned long  dataForkLength, unsigned short  fdInfo, unsigned long  fileCreationDate, unsigned long  fileModificationDate)
  43. {
  44.  
  45.   unsigned char        nameLength;
  46.   
  47.     fLink = 0;
  48.  
  49.     fFileIndex = fileIndex;
  50.     
  51.     fFileSize = resourceForkLength + dataForkLength;
  52.  
  53.     fType = fileType;
  54.     
  55.     fCreator = fileCreator;
  56.     
  57.     fResourceForkOffset = resourceForkOffset;
  58.     fResourceForkLength = resourceForkLength;
  59.     fDataForkOffset = dataForkOffset;
  60.     fDataForkLength = dataForkLength;
  61.     
  62.     fFinderFlags = fdInfo;
  63.     
  64.     fFileCreationDate = fileCreationDate;
  65.     fFileModificationDate = fileModificationDate;
  66.     
  67.     nameLength = (unsigned char)*fileName;
  68.     
  69.     BlockMove(fileName, &fRealName, nameLength+1);
  70.     
  71. }
  72.  
  73.  
  74.  
  75. //--------------------------------------------------------------------------------------------------------
  76.  
  77. CEnclosFileSummaryList::CEnclosFileSummaryList()
  78. {
  79.     fHeadSummary = 0;
  80.     fTailSummary = 0;
  81.     fCount = 0;
  82. }
  83.  
  84.  
  85. //---------------------------------------------------
  86. CEnclosFileSummaryList::~CEnclosFileSummaryList()
  87. {
  88.  
  89.     CEnclosFileSummary* aSummary = fHeadSummary;
  90.     CEnclosFileSummary* nextSummary = 0;
  91.  
  92.  
  93.         //    Delete all the objects in the list.
  94.  
  95.  
  96.     while( aSummary != 0 ) {
  97.         nextSummary = aSummary->fLink;
  98.         delete aSummary;
  99.         aSummary = nextSummary;
  100.     }
  101.  
  102.  
  103. }
  104.  
  105.  
  106. //-------------------------------------------------------------------
  107. void CEnclosFileSummaryList::Append(unsigned long  fileIndex, unsigned long fileSize, OSType fileType, OSType    fileCreator, StringPtr    fileName,
  108.                                     unsigned long  resourceForkOffset, unsigned long  resourceForkLength, unsigned long  dataForkOffset,
  109.                                     unsigned long  dataForkLength, unsigned short  fdInfo, unsigned long  fileCreationDate, unsigned long  fileModificationDate)
  110. {
  111.     CEnclosFileSummary* msgSummary = new CEnclosFileSummary(fileIndex, fileSize, fileType, fileCreator, fileName, resourceForkOffset, resourceForkLength, dataForkOffset, dataForkLength, fdInfo, fileCreationDate, fileModificationDate);
  112.     this->Append(msgSummary);
  113.     
  114. }
  115.  
  116.  
  117. //-------------------------------------------------------------------
  118. void CEnclosFileSummaryList::Append(CEnclosFileSummary* summary)
  119. {
  120.     if( fHeadSummary == 0 ) {
  121.     
  122.         ASSERT(fTailSummary==0);
  123.         fHeadSummary = summary;
  124.         fTailSummary = summary;
  125.         summary->fLink = 0;
  126.         
  127.     } else {
  128.     
  129.         ASSERT(fHeadSummary!=0);
  130.         ASSERT(fTailSummary!=0);
  131.         ASSERT(fTailSummary->fLink==0);
  132.         fTailSummary->fLink = summary;
  133.         fTailSummary = summary;
  134.         summary->fLink = 0;
  135.     };
  136.  
  137.     fCount++;
  138. }
  139.  
  140.  
  141. //-------------------------------------------------------------------
  142. CEnclosFileSummary*    CEnclosFileSummaryList::operator [](long i)
  143. {
  144.     ASSERT(i<=fCount);
  145.  
  146.     CEnclosFileSummary* aSummary = fHeadSummary;
  147.     while( (aSummary != 0) && (i > 0) )  {
  148.         aSummary = aSummary->fLink;
  149.         i--;
  150.     };
  151.  
  152.  
  153.     return aSummary;
  154.     
  155. }
  156.  
  157.  
  158.  
  159.  
  160.  
  161.